package com.zyp.servlet;

import com.zyp.service.TheClassDaoService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(name = "TheClassDeleteServlet",urlPatterns = "/theClassDeleteServlet")
public class TheClassDeleteServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        //获取需要删除的班级
        String classID = request.getParameter("classID");

        //执行sql
        TheClassDaoService theClassDaoService = new TheClassDaoService();
        int deleteService = theClassDaoService.getDeleteService(classID);
        HttpSession session = request.getSession();
        //将结果绑定
        session.setAttribute("DeleteClassID",deleteService);

        response.sendRedirect("http://localhost:8081/task_5module_1/theClassdelete.jsp");

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
